package com.example.xiaodu.yuejian12.Fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.xiaodu.yuejian12.Adapter.ActivityAdapter;
import com.example.xiaodu.yuejian12.Adapter.ClubAdapter;
import com.example.xiaodu.yuejian12.Bean.ActivityBean;
import com.example.xiaodu.yuejian12.Bean.ClubBean;
import com.example.xiaodu.yuejian12.Listener.RetrofitListener;
import com.example.xiaodu.yuejian12.Model.UserModel;
import com.example.xiaodu.yuejian12.R;

import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class ClubFragment extends Fragment {

    private RecyclerView recyclerView;
    private UserModel userModel;
    private RetrofitListener<List<ClubBean>> listener;
    private LinearLayoutManager linearLayoutManager;
    private ClubAdapter clubAdapter;

    public  View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_club, container, false);
        clubAdapter = new ClubAdapter();
        recyclerView = view.findViewById(R.id.clubRecyclerView);
        linearLayoutManager = new LinearLayoutManager(getActivity());
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setAdapter(clubAdapter);  //set adapter

        listener = new RetrofitListener<List<ClubBean>>() {
            @Override
            public void onSuccess(List<ClubBean> list) {
                clubAdapter.setData(list);
            }

            @Override
            public void onFail(String msg) {


            }
        };
               userModel=new UserModel();
        userModel.getAllClub(listener);
        return view;
    }


}
